import Vue from 'vue'
import VueRouter from 'vue-router'
import homeView from "../views/homeView.vue";
import cartView from "../views/cartView.vue";
import categoryView from "../views/categoryView.vue";
import userView from "../views/userView.vue";


Vue.use(VueRouter)

const routes = [


  { path: '/', redirect: '/home' },
  
  {
    path: '/home',
    name: 'home',
    component: homeView
  },
  {
    path: '/cart',
    name: 'cart',
    component: cartView
  },
  {
    path: '/category',
    name: 'category',
    component: categoryView
  },
  {
    path: '/user',
    name: 'user',
    component: userView
  },
  {
    path: '/list',
    name: 'list',
    component: () => import('../views/listView.vue')
  },
  {
    path: '/item',
    name: 'item',
    component: () => import('../views/itemView.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/loginView.vue')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('../views/searchView.vue')
  },
  {
    path: '/userlogin',
    name: 'userlogin',
    component: () => import('../views/userloginView.vue')
  },
  {
    path: '/enter',
    name: 'enter',
    component: () => import('../views/enterView.vue')
  },
  {
    path: '/address',
    name: 'address',
    component: () => import('../views/addressView.vue')
  },
  {
    path: '/havebuy',
    name: 'havebuy',
    component: () => import('../views/havebuyView.vue')
  },
  {
    path: '/isreceive',
    name: 'isreceive',
    component: () => import('../views/isreceiveView.vue')
  },
  {
    path: '/isEvaluation',
    name: 'isEvaluation',
    component: () => import('../views/isEvaluationView.vue')
  },
  {
    path: '/after',
    name: 'after',
    component: () => import('../views/isafterView.vue')
  },
  {
    path: '/quitbuy',
    name: 'quitbuy',
    component: () => import('../views/quitbuyView.vue')
  }
]

// 注意:解决路由跳转问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location){
  return originalPush.call(this,location).catch(err=>err);
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior () {
    return { x: 0, y: 0 }
  }
})

export default router
